// Copyright DustedPixels.com 2008. All rights reserved.

package com.dustedpixels.jasmin.video;

/**
 * @author micapolos@gmail.com (Michal Pociecha-Los)
 */
public interface VideoOutput {
  /**
   * Sets size of produced video. Should be called once before producing the
   * first frame, and every time size of produced frame changes.
   * 
   * @param width width in pixels >= 0
   * @param height in pixels >= 0
   */
  void setSize(int width, int height);

  /**
   * Returns true, if video system needs new frame to be produced.
   * 
   * @return
   */
  boolean needsFrame();

  /**
   * Starts producing new video frame. Returns array of integers, which should be
   * filled with frame content. After frame is produced,
   * <code>endFrame</code> should be called. Note, that content of provided
   * array is unspecified, and thus should be cleared (or fully overwritten).
   * 
   * @return array of integers to put frame content
   * @throws IllegalArgumentException if frame production has already been
   *         started but not submitted.
   */
  int[] beginFrame();

  /**
   * Submits produced frame.
   * 
   * @throws IllegalArgumentException if <code>beginFrame</code> has not been
   *         called.
   */
  void endFrame();
}
